package cn.xuyanwu.spring.file;

import javax.activation.FileTypeMap;
import javax.activation.MimetypesFileTypeMap;
import javax.validation.constraints.NotNull;
import java.io.File;

public class ContentTypeSpy {
    private static final FileTypeMap fileTypeMap = new MimetypesFileTypeMap();
    public static String getContentTypeByFile(@NotNull  File file){
        return fileTypeMap.getContentType(file);
    }

    public static String getContentTypeByFileName(@NotNull  String fileName){
        return fileTypeMap.getContentType(fileName);
    }
}
